<div class="row">
	<div class="col-xs-12">
		<div id="table-sqlrun-toolbar">
    		<div class="btn-group btn-group-sm">
    		 <button id="refresh" class="btn btn-purple btn-sm no-border" >
                 <i class="ace-icon fa fa-refresh bigger-110 "></i>刷新
             </button>
             <button id="reset" class="btn btn-purple btn-sm no-border" >
                 <i class="ace-icon fa fa-book bigger-110 "></i>重置
             </button>
            </div>
        </div>
		<table id="SqlRunTable" class="table table-hover"
			data-toolbar="#table-sqlrun-toolbar" 
			data-pagination="true" data-page-size="10"
			data-page-list="[]" data-striped="true">
			<thead>
				<tr>
					<th data-field="id">序号</th>
					<th data-field="SQL">SQL语句</th>
					<th data-field="ExecuteCount" data-sortable="true">执行次数</th>
					<th data-field="TotalTime">总计耗时(毫秒)</th>
					<th data-field="MaxTimespan" data-sortable="true">最长耗时(毫秒)</th>
					<th data-field="InTransactionCount">事务次数</th>
					<th data-field="ErrorCount">错误数</th>
					<th data-field="EffectedRowCount">更新行数</th>
					<th data-field="FetchRowCount">读取行数</th>
					<th data-field="RunningCount">执行中</th>
					<th data-field="ConcurrentMax">并发数</th>
				</tr>
			</thead>
			<tbody></tbody>
		</table>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	function sqlInit(){
		$.ajax({
			type: 'POST',
			url: "system/monitor/druid/res/sql.json?rd="+$.now(),
			success: function(data) {
				$("#SqlRunTable").bootstrapTable("destroy");
				var sqlStatList = data.Content;
				if(sqlStatList==null){ 
					$("#SqlRunTable").bootstrapTable({data:[]});
					return;
				}
				for ( var i = 0; i < sqlStatList.length; i++) {
					sqlStatList[i].id=i+1;
				}
				$("#SqlRunTable").bootstrapTable({data:sqlStatList});
			},
			dataType: "json"
		});
	}
	
	$('#reset').click(function(){
		$.ajax({
			type: 'POST',
			url: "system/monitor/druid/res/reset-all.json",
			success: function(data) {
				if (data.ResultCode == 1) {
					TipMsg.error("所有数据统计已重置.", 0);
					sqlInit();
				}
			},
			dataType: "json"
		});
	});
	
	$('#refresh').click(function(){
		sqlInit();
	});
	sqlInit();
});
</script>